// CBData.cpp: implementation of the CCBData class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Five.h"
#include "CBData.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCBData::CCBData():m_size(CHESS_GRID_NUM)
{
	Init();
}

CCBData::~CCBData()
{

}

void CCBData::Init()
{
	ASSERT(m_size>0);

	::memset(m_data,0,sizeof(m_data));

	m_history.clear();
}

void CCBData::Unset()
{
	if(m_history.size()>0)
	{
		ChessStep temp = m_history.back();
		m_history.pop_back();
		m_data[temp.x][temp.y] = NONE_CHESS;
	}
}

#if defined _DEBUG
void CCBData::Dump()
{
	TRACE("======start chess dump========");
	for(int y=0;y<m_size;++y)
	{
		CString str;
		for(int x=0;x<m_size;++x)
		{
			char c = Get(x,y);
			if(c == NONE_CHESS)
			{
				str += " ";
			}
			else
			{
				str += c;
			}
		}
		TRACE(str);
	}
	TRACE("======end chess dump========");
}
#endif
